<template>
	<view>
		<!-- 搜索框 -->
		<view class="search">
			<image src="../../static/home_imgs/search.png"></image>
			<input class="input" type="text" placeholder="请输入店铺名称" :value="Value" @input="getValue">
		</view>
		<!-- 店铺列表 -->
		<view>
			<view v-for="item in shopList2" :key="item.id" class="shop">
				<!-- 左边头像 -->
				<view class="shop-img">
					<image :src="item.src"></image>
				</view>
				<!-- 右边介绍 -->
				<view class="shop-detail">
					<!-- 店铺名称 -->
					<view class="shop-detail-head">
						<view class="shop-text1">{{item.name}}</view>
						<view>
							<text class="shop-text2">评分</text>
							<text class="shop-text3">{{item.score}}</text>
						</view>
						<view class="shop-text4">No.{{item.id}}</view>
					</view>
					<!-- 星星 -->
					<view class="shop-detail-middle">
						<image class="star" v-for="index of 4" :key="index" src="../../static/home_imgs/star2.png">
						</image>
						<image class="star" src="../../static/home_imgs/star.png"></image>
					</view>
					<!-- 销量 -->
					<view class="shop-detail-bottom">
						<text class="shop-text5">销量{{item.sales}}</text>
						<view style="display: flex;">
							<view class="shop-detail-bottom-img">
								<image src="../../static/home_imgs/airplane.png" />
							</view>
							<text class="shop-text6">{{item.distance}}</text>
						</view>
						<view class="shop-detail-bottom-button" :data-id="item.id" @click="enter">进店</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	var shopList=getApp().globalData.shopList
	export default {
		data() {
			return {
				Value: null,
				shopList2: []
			}
		},
		methods: {
			getValue(e) {
				this.shopList2 = []
				this.Value = e.detail.value
				for (var i = 0; i < shopList.length; i++) {
					let str = shopList[i].name
					if (str.search(this.Value) != -1) {
						this.shopList2.push(shopList[i])
					}
				}
			},
			enter(e){
				let id = e.currentTarget.dataset.id
				wx.navigateTo({
					url: "../../other_pages/shop_detail/shop_detail?shopId=" + id
				})
			}
		},
		onLoad(options){
			this.shopList2=shopList
			let name=options.name
			wx.setNavigationBarTitle({
				title:name
			})
		}
	}
</script>

<style lang="scss">
	.search {
		margin: 1vh auto;
		height: 8vw;
		font-size: 3vw;
		display: flex;
		align-items: center;
		width: 97vw;
		background-color: #e6e6e6;
		border-radius: 5vw;
	}

	.search image {
		margin: 0 3vw;
		width: 5vw;
		height: 5vw;
	}

	.input {
		width: 85vw;
	}

	.shop {
		width: 100vw;
		height: 25vw;
		margin: 1vw 0 1vw 0;
		padding: 3vw 3vw 0;
		display: flex;
		background-color: #dfe8ff;
	}

	.shop-img image {
		margin-right: 5vw;
		width: 20vw;
		height: 20vw;
	}

	.shop-detail {
		width: 67vw;
		height: 20vw;
	}

	.shop-detail-head {
		font-size: 13px;
		display: flex;
		justify-content: space-between;
	}

	.shop-text2 {
		padding: 1px;
		margin-right: 1vw;
		background-color: #ff958d;
		color: #ffffff;
		border-radius: 3px;
	}

	.shop-detail-middle {
		margin: 2.5vw 0;
	}

	.star {
		width: 4vw;
		height: 4vw;
	}

	.shop-detail-bottom {
		display: flex;
		justify-content: space-between;
		align-items: flex-end;
	}

	.shop-text5 {
		font-size: 10px;
		color: #00000060;
	}

	.shop-detail-bottom-img {
		margin: 0vw 0 -1vw 0;
	}

	.shop-detail-bottom-img image {
		margin: -1vw 0 0 0;
		width: 5vw;
		height: 5vw;
	}

	.shop-detail-bottom-button {
		border-radius: 5px;
		padding: 1px 3px;
		border: 1px solid #00000030;
		font-size: 13px;
		color: #ffffff;
		background-color: #a195ec;
	}

	.shop-text6 {
		font-size: 13px;
	}
</style>
